package mypazar.customer;

import jason.environment.grid.Location;
import mypazar.agent.PersonAgent;
import mypazar.jenamodel.PazarVocabulary;
import mypazar.pazar.Stall;
import tr.edu.ege.seagent.planner.htn.Action;
import tr.edu.ege.seagent.planner.htn.ExecutionMethod;
import tr.edu.ege.seagent.planner.htn.Outcome;

import com.hp.hpl.jena.rdf.model.Model;

/**
 * Action class of ACFindLowerPrice.
 */
public class ACFindLowerPrice extends Action {

	/**
	 * Location outcome.
	 */
	@Outcome
	private Location Location;

	/**
	 * Returns the value of the Location outcome.
	 */
	public Location getLocation() {
		return this.Location;
	}

	/**
	 * Sets the value of the Location outcome.
	 */
	public void setLocation(Location Location) {
		this.Location = Location;
	}

	/**
	 * SmanName outcome.
	 */
	@Outcome
	private String SmanName;

	/**
	 * Returns the value of the SmanName outcome.
	 */
	public String getSmanName() {
		return this.SmanName;
	}

	/**
	 * Sets the value of the SmanName outcome.
	 */
	public void setSmanName(String SmanName) {
		this.SmanName = SmanName;
	}

	/**
	 * Execution method.
	 */
	@ExecutionMethod
	public void execute() {
		Model beliefBase = (Model) getHeapValue(PersonAgent.BELIEF_BASE_ITEM_NAME);

		String PERSON_URI = PazarVocabulary.NS_URI
				+ getAgentIdentifier().toString().substring(0, 7);
		Stall st = new CustomerBeliefBaseOperations().getLowestPrice(
				PERSON_URI, beliefBase);

		this.setLocation(new Location(st.getX(), st.getY()));
		this.setSmanName(PazarVocabulary.SALESMAN_NAME_PREFIX + st.getStallNO());
	}
}
